package com.xique.job.task;

import com.xique.park.api.RemoteParkCarService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 黑名单定时任务
 *
 * @author WLD
 */
@Slf4j
@RequiredArgsConstructor
@Component
public class BlackCarTask {

    private final RemoteParkCarService remoteParkCarService;

    /**
     * 1.删除超过了有效期的黑名单车辆
     * 2.下发到了启用日期的黑名单车辆
     */
    public void handleBlackExpire() {
        removeBlackExpire();
        downEnableBlackCar();
    }

    public void removeBlackExpire() {
        log.info("[定时任务]-开始删除黑名单车辆");
        long startTime = System.currentTimeMillis();
        remoteParkCarService.removeBlackExpire();
        log.info("[定时任务]-删除黑名单车辆执行时间：{}", System.currentTimeMillis() - startTime);
    }

    public void downEnableBlackCar() {
        log.info("[定时任务]-下发到了启用日期的黑名单车辆");
        long startTime = System.currentTimeMillis();
        remoteParkCarService.downEnableBlackCar();
        log.info("[定时任务]-下发到了启用日期的黑名单车辆执行时间：{}", System.currentTimeMillis() - startTime);
    }

}
